from typing import List


class Solution:
    def canChoose(self, groups: List[List[int]], nums: List[int]) -> bool:
        i, j = 0, 0
        while i < len(nums):
            if i + len(groups[j]) > len(nums):
                return False
            if nums[i:i + len(groups[j])] == groups[j]:
                i += len(groups[j])
                j += 1
                if j == len(groups):
                    return True
            else:
                i += 1
        return False


if __name__ == "__main__":
    print(Solution().canChoose(groups=[[1, -1, -1], [3, -2, 0]], nums=[1, -1, 0, 1, -1, -1, 3, -2, 0]))  # True
    print(Solution().canChoose(groups=[[10, -2], [1, 2, 3, 4]], nums=[1, 2, 3, 4, 10, -2]))  # False
    print(Solution().canChoose(groups=[[1, 2, 3], [3, 4]], nums=[7, 7, 1, 2, 3, 4, 7, 7]))  # False

    # 测试用例132
    print(Solution().canChoose(groups=[[1, 2]], nums=[1, 3, 2]))  # False
